import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        String res = Integer.toBinaryString(n);
        List<Integer> list = new ArrayList<>();
        int count = 0;
        for (int i = 0; i < res.length(); i++) {
             if (res.charAt(i) == '1') {
                 count++;
             } else {
                 list.add(count);
                 count = 0;
             }
             if (i == res.length()-1) {
                 list.add(count);
             }
        }
        Collections.sort(list);
        System.out.println(list.get(list.size()-1));
    }
}
